<?php

/*
 * Copyright (c) Madbit 2012. All Rights Reserved.
 * Reproduction in whole or in part is prohibited without the
 * written consent of the copyright owner.
 */
$includes = array();

function includeFile($path) {
    global $includes;
    
    $configFilePath = dirname(__FILE__)."/../conf/config.inc.php";
    if(!in_array("conf/config.inc.php", $includes)) 
        include ($configFilePath);           
    
    if(!in_array($path, $includes)) {
        include $_SERVER["DOCUMENT_ROOT"].$applicationConfig['baseDir']."/".$path;
        array_push($includes, $path);        
    }
}

spl_autoload_register("includeFile");

function includeFileOnce($path) {
   global $includes;
   
    $configFilePath = dirname(__FILE__)."/../conf/config.inc.php";
    if(!in_array("conf/config.inc.php", $includes)) 
        include ($configFilePath);           
    
    if(!in_array($path, $includes)) {
        include_once $_SERVER["DOCUMENT_ROOT"].$applicationConfig['baseDir']."/".$path;
        array_push($includes, $path);        
    }
}

spl_autoload_register("includeFileOnce");

?>
